const {
  Controller,
} = require('uni-cloud-router')

const ResponseUtil = require('../utils/Response.js')

module.exports = class ChildController extends Controller {
  async list() {
    const {
      ctx,
      service,
    } = this
    const {
      openId,
    } = ctx

    return service.child.list({ openId })
  }

  async add() {
    const {
      ctx,
      service,
    } = this
    const {
      openId,
    } = ctx
    const { id, name } = ctx.event

    return service.child.add({ openId, id, name })
  }

  async remove() {
    const {
      ctx,
      service,
    } = this
    const {
      openId,
    } = ctx
    const { id } = ctx.event

    return service.child.remove({ openId, id })
  }
}
